<div class="ant-modal-root">
    <div class="ant-modal-mask"></div>
    <div tabindex="-1" class="ant-modal-wrap " role="dialog" aria-labelledby="rcDialogTitle10">
        <div role="document" class="ant-modal" style="width: 500px;">
            <div tabindex="0" aria-hidden="true" style="width: 0px; height: 0px; overflow: hidden; outline: none;">
            </div>
            <div class="ant-modal-content">
                <div class="ant-modal-header">
                    <div class="ant-modal-title" id="rcDialogTitle10">登录</div>
                </div>
                <div class="ant-modal-body">
                    <form class="ant-form ant-form-horizontal" action="?{{query}}" method="POST">
                        <input type="hidden" name="token" value="{{crsf_token}}">
                        <div class="ant-row ant-form-item">
                            <div class="ant-col ant-col-5 ant-form-item-label"><label for="basic_username"
                                    class="ant-form-item-required" title="用户名">用户名</label></div>
                            <div class="ant-col ant-col-18 ant-form-item-control">
                                <div class="ant-form-item-control-input">
                                    <div class="ant-form-item-control-input-content"><input type="text"
                                            id="basic_username" class="ant-input" name="name" placeholder="请输入用户名">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="ant-row ant-form-item">
                            <div class="ant-col ant-col-5 ant-form-item-label"><label for="basic_password"
                                    class="ant-form-item-required" title="密码">密码</label></div>
                            <div class="ant-col ant-col-18 ant-form-item-control">
                                <div class="ant-form-item-control-input">
                                    <div class="ant-form-item-control-input-content"><span
                                            class="ant-input-password ant-input-affix-wrapper"><input action="click"
                                                id="basic_password" type="password" name="password" placeholder="请输入密码"
                                                class="ant-input"></span></div>
                                </div>
                            </div>
                        </div>
                        <div class="ant-row ant-form-item" id="form-item-captcha" style="display: {{captcha_display}};">
                            <div class="ant-col ant-col-5 ant-form-item-label" style="display: block; float: left; width: 20.83%;"><label for="basic_captcha" class="ant-form-item-required"
                                    title="验证码">验证码</label></div>
                            <div class="ant-col ant-col-18 ant-form-item-control">
                                <div class="ant-form-item-control-input">
                                    <div class="ant-form-item-control-input-content">
                                        <div class="ant-row" style="margin-left: -4px; margin-right: -4px;">
                                            <div class="ant-col ant-col-12" style="padding-left: 4px; padding-right: 4px;">
                                                <input action="click" id="basic_captcha" type="text" name="captcha" class="ant-input" placeholder="大小写敏感">
                                            </div>
                                            <div class="ant-col ant-col-12" style="padding-left: 4px; padding-right: 4px;">
                                                <img id="img_captcha" height="32" src="{{captcha_url}}" onclick="this.src = '{{captcha_url}}?t=' + Date.now();">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="ant-row ant-form-item">
                            <div class="ant-col ant-col-18 ant-col-sm-offset-5 ant-form-item-control">
                                <div class="ant-form-item-control-input">
                                    <div class="ant-form-item-control-input-content">
                                        <button type="submit" class="ant-btn ant-btn-primary"><span>登录</span></button>
                                        <span style="color: #ff4d4f" id="error-show">{{error}}</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    (function () {
        var _0x5537 = ['c3BsaXQ=', 'bWFw', 'bGVuZ3Ro', 'aGFz', 'Zmxvb3I=', 'cmFuZG9t', 'dG9TdHJpbmc=', 'c3Vic3RyaW5n']; (function (_0x7f77f0, _0x22c48b) { var _0x5a8baf = function (_0x41bf08) { while (--_0x41bf08) { _0x7f77f0['push'](_0x7f77f0['shift']()); } }; _0x5a8baf(++_0x22c48b); }(_0x5537, 0xbf)); var _0x39f2 = function (_0x24432e, _0x3f2642) { _0x24432e = _0x24432e - 0x0; var _0x175ec8 = _0x5537[_0x24432e]; if (_0x39f2['wLgwpd'] === undefined) { (function () { var _0x4319c7 = function () { var _0x56a64c; try { _0x56a64c = Function('return\x20(function()\x20' + '{}.constructor(\x22return\x20this\x22)(\x20)' + ');')(); } catch (_0x540c91) { _0x56a64c = window; } return _0x56a64c; }; var _0x39df57 = _0x4319c7(); var _0x71c38c = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; _0x39df57['atob'] || (_0x39df57['atob'] = function (_0x41f8c0) { var _0x4bdff9 = String(_0x41f8c0)['replace'](/=+$/, ''); for (var _0xe778dd = 0x0, _0x3d3b1c, _0x34e95e, _0x2bbe6 = 0x0, _0x3a95f2 = ''; _0x34e95e = _0x4bdff9['charAt'](_0x2bbe6++); ~_0x34e95e && (_0x3d3b1c = _0xe778dd % 0x4 ? _0x3d3b1c * 0x40 + _0x34e95e : _0x34e95e, _0xe778dd++ % 0x4) ? _0x3a95f2 += String['fromCharCode'](0xff & _0x3d3b1c >> (-0x2 * _0xe778dd & 0x6)) : 0x0) { _0x34e95e = _0x71c38c['indexOf'](_0x34e95e); } return _0x3a95f2; }); }()); _0x39f2['ldEUox'] = function (_0x4ffbb5) { var _0xdd9a03 = atob(_0x4ffbb5); var _0x17f85b = []; for (var _0x197b9c = 0x0, _0x1f0490 = _0xdd9a03['length']; _0x197b9c < _0x1f0490; _0x197b9c++) { _0x17f85b += '%' + ('00' + _0xdd9a03['charCodeAt'](_0x197b9c)['toString'](0x10))['slice'](-0x2); } return decodeURIComponent(_0x17f85b); }; _0x39f2['jLKWhY'] = {}; _0x39f2['wLgwpd'] = !![]; } var _0x5a6400 = _0x39f2['jLKWhY'][_0x24432e]; if (_0x5a6400 === undefined) { _0x175ec8 = _0x39f2['ldEUox'](_0x175ec8); _0x39f2['jLKWhY'][_0x24432e] = _0x175ec8; } else { _0x175ec8 = _0x5a6400; } return _0x175ec8; }; var incrypt_account = function (_0x3eb7ab, _0x23fcd6) { var _0x2ba3cb = new Set(_0x3eb7ab[_0x39f2('0x0')](0x4, 0xc)[_0x39f2('0x1')]('')[_0x39f2('0x2')](function (_0x3ed537) { return parseInt(_0x3ed537, 0x10); })); var _0x18770b = ''; for (var _0x4e4e09 = 0x0; _0x4e4e09 < _0x23fcd6[_0x39f2('0x3')]; _0x4e4e09++) { var _0xe2a639 = _0x23fcd6[_0x4e4e09]; while (_0x2ba3cb[_0x39f2('0x4')](_0x18770b[_0x39f2('0x3')])) { _0x18770b += Math[_0x39f2('0x5')](Math[_0x39f2('0x6')]() * 0x24)[_0x39f2('0x7')](0x24); } _0x18770b += _0xe2a639; } return _0x18770b; };
        var form = document.querySelector('form');
        // @ts-check
        /** @type { HTMLInputElement } */
        var token_input = form.querySelector('[name="token"]');
        var token = token_input.value

        /** @type { HTMLInputElement } */
        var name_input = form.querySelector('[name="name"]');
        /** @type { HTMLInputElement } */
        var pass_input = form.querySelector('[name="password"]');
        /** @type { HTMLInputElement } */
        var captcha_input = form.querySelector('[name="captcha"]');
        var error_show = document.getElementById('error-show');

        form.addEventListener('submit', function (e) {
            e.preventDefault();
            var str = btoa(JSON.stringify({
                name: name_input.value,
                password: pass_input.value,
            }, null, 1));

            var account = incrypt_account(token, str)
            var xhr = new XMLHttpRequest()
            xhr.addEventListener('readystatechange', function (e) {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        const res = JSON.parse(xhr.responseText);
                        if (res.error) {
                            error_show.innerText = res.error;
                        } else {
                            if (res.msg) {
                                alert(res.msg)
                            }
                            location.href = "{{query}}";
                        }
                    }
                }
            })
            xhr.open(form.method, form.action)
            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            xhr.setRequestHeader('x-requested-with', 'XMLHttpRequest',);
            xhr.send('crsf_token=' + token + '&account=' + account + '&captcha=' + captcha_input.value)
        })
    })();
</script>
